package com.iwhalecloud.citybrain.flow.platform.manager.application.service.impl.task;

import com.iwhalecloud.citybrain.flow.platform.manager.application.service.ActivityCompletedPostProcessor;
import com.iwhalecloud.citybrain.flow.platform.manager.application.service.FlowFormHistoryService;
import com.iwhalecloud.citybrain.flow.platform.manager.domain.exception.EventCallSuspendException;
import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author SiJiang
 * @createTime 2021/9/1 4:11 下午
 * @description
 */

@Service
public class ProcessFlowFormHistoryRecordProcessor implements ActivityCompletedPostProcessor {
    @Autowired
    private FlowFormHistoryService flowFormHistoryService;
    @Override
    public void process(FlowableActivityEventImpl activityEvent) throws EventCallSuspendException {
        //如果不是开始节点，那么不进行记录
        if (!"startEvent".equals(activityEvent.getActivityType())) {
            return;
        }
        flowFormHistoryService.recordProcessHistoryExternalForm(activityEvent.getProcessInstanceId());
    }
}
